//括号匹配

#include "SqStack.cpp"
#include <iostream>

using namespace std;

bool bracketcheck(string s)
{
    SqStack S;
    InitStack(S);
    for (int i = 0; i < s.length(); ++i)
    {
        switch (s[i])
        {
        case '(':
        case '[':
        case '{':
            Push(S, s[i]); //压栈
            break;
        case ')':
        case ']':
        case '}':
            if (StackEmpty(S))
                return false;
            else if (GetTop(S) == '(' && s[i] == ')')
                Pop(S); //若匹配，则出栈
            else if (GetTop(S) == '[' && s[i] == ']')
                Pop(S); //若匹配，则出栈
            else if (GetTop(S) == '{' && s[i] == '}')
                Pop(S); //若匹配，则出栈
            else
                return false; //若不匹配，则返回false
            break;
        }
    }
    if (StackEmpty(S))
        return true;
    else
        return false;
}

int main()
{
    string s;
    cin >> s;
    cout << (bracketcheck(s) ? "true" : "false");
    return 0;
}